﻿<script type="text/javascript">
$(function () {

    //初始化质押方上方表格
    xsht_kh_datagrid();


    $("#btn_xshtkh_search_init").click(function () {
        var xsxt_xsdh = $("[name='xsxt_xsdh']").val();
        var carNo = $("[name='carNo']").val();
        var weight = $("[name='weight']").val();
        var bindNo = $("[name='bindNo']").val();

        var queryParam =
        {
            xsxt_xsdh: xsxt_xsdh,
            carNo: carNo,
            weight: weight,
            bindNo: bindNo
        };

        $('#xsht_kh_grid').edatagrid({
            url: $.webPath() + '/htgl/xshtgl/xshtgl_xsmx?xshtId=' + $("#xshtId").val(),
            fitColumns: false,
            singleSelect: true,
            fit: true,
            showFooter: false,
            rownumbers: true,
            queryParams: queryParam,
            toolbar: "#toolbar_xshtkh_search",
            frozenColumns: [
                [
                    {field: 'wzgg.id', title: '物资编码ID', hidden: true},
                    {field: 'kh.id', title: 'khID', hidden: true},
                    {field: 'wzgg.code', title: '物资编码', hidden: true},
                    {field: 'xszxh', title: '合同子项号', width: 85},
                    {field: 'wzgg.name', title: '品名', width: 100},
                    {field: 'wzgg.cz', title: '材质', width: 85},
                    {field: 'wzgg.ggxh', title: '规格', width: 85},
                    {field: 'carNo', title: '车皮号', width: 85},
                    {field: 'bindNo', title: '捆包号', width: 120}
                ]
            ],
            columns: [
                [
                    {field: 'kh.khbm', title: '卡号', width: 130},
                    {field: 'xscb', title: '库存单价',
                        formatter: function (value) {
                            var sl = formatJe(value, ",");
                            return sl;
                        }, width: 70},
                    {field: 'js', title: '件数',
                        formatter: function (value) {
                            var sl = formatSlForHtml(value, ",");
                            return sl;
                        }, width: 70},
                    {field: 'sbsl', title: '数量（吨）',
                        formatter: function (value) {
                            var sl = formatSlForHtml(value, ",");
                            return sl;
                        }, width: 100},
                    {field: 'hsj', title: '合同单价(含税)',
                        formatter: function (value) {
                            var sl = formatJe(value, ",");
                            return sl;
                        }, width: 100},
                    {field: 'bhsj', title: '合同单价(不含税)',
                        formatter: function (value) {
                            var sl = formatJe(value, ",");
                            return sl;
                        }, width: 100},
                    {field: 'hse', title: '含税额(元)',
                        formatter: function (value) {
                            var sl = formatJe2(value, ",");
                            return sl;
                        }, width: 100},
                    {field: 'bhse', title: '无税额(元)',
                        formatter: function (value) {
                            var sl = formatJe2(value, ",");
                            return sl;
                        }, width: 100}
                ]
            ],
            loadFilter: function (data) {
                $.each(data.rows, function () {
                    var bhsj = Math.round(this.bhsj * 10000) / 10000;
                    var hsj = Math.round(this.hsj * 10000) / 10000;
                    var sl = Math.round(this.sbsl * 10000) / 10000;

                    if (this.bhsj) {
                        this.bhse = Math.round(multiply(sl, bhsj) * 100) / 100;
                    }
                    if (this.hsj) {
                        this.hse = Math.round(multiply(sl, hsj) * 100) / 100;
                    }
                })
                return data;
            },
            onSelect: function (rowIndex, rowData) {
                $(selected_xsht_kh).datagrid('appendRow', rowData);
            }
        });
    });

})


function xsht_kh_datagrid() {
    $('#xsht_kh_grid').edatagrid({
        url: $.webPath() + '/htgl/xshtgl/xshtgl_xsmx?xshtId=' + $("#xshtId").val(),
        fitColumns: false,
        singleSelect: true,
        fit: true,
        showFooter: false,
        rownumbers: true,
        toolbar: "#toolbar_xshtkh_search",
        frozenColumns: [
            [
                {field: 'wzgg.id', title: '物资编码ID', hidden: true},
                {field: 'kh.id', title: 'khID', hidden: true},
                {field: 'wzgg.code', title: '物资编码', hidden: true},
                {field: 'xszxh', title: '合同子项号', width: 85},
                {field: 'wzgg.name', title: '品名', width: 100},
                {field: 'wzgg.cz', title: '材质', width: 85},
                {field: 'wzgg.ggxh', title: '规格', width: 85},
                {field: 'carNo', title: '车皮号', width: 85},
                {field: 'bindNo', title: '捆包号', width: 120}
            ]
        ],
        columns: [
            [
                {field: 'kh.khbm', title: '卡号', width: 130},
                {field: 'xscb', title: '库存单价',
                    formatter: function (value) {
                        var sl = formatJe(value, ",");
                        return sl;
                    }, width: 70},
                {field: 'js', title: '件数',
                    formatter: function (value) {
                        var sl = formatSlForHtml(value, ",");
                        return sl;
                    }, width: 70},
                {field: 'sbsl', title: '数量（吨）',
                    formatter: function (value) {
                        var sl = formatSlForHtml(value, ",");
                        return sl;
                    }, width: 100},
                {field: 'hsj', title: '合同单价(含税)',
                    formatter: function (value) {
                        var sl = formatJe(value, ",");
                        return sl;
                    }, width: 100},
                {field: 'bhsj', title: '合同单价(不含税)',
                    formatter: function (value) {
                        var sl = formatJe(value, ",");
                        return sl;
                    }, width: 100},
                {field: 'hse', title: '含税额(元)',
                    formatter: function (value) {
                        var sl = formatJe2(value, ",");
                        return sl;
                    }, width: 100},
                {field: 'bhse', title: '无税额(元)',
                    formatter: function (value) {
                        var sl = formatJe2(value, ",");
                        return sl;
                    }, width: 100}
            ]
        ],
        loadFilter: function (data) {
            $.each(data.rows, function () {
                var bhsj = Math.round(this.bhsj * 10000) / 10000;
                var hsj = Math.round(this.hsj * 10000) / 10000;
                var sl = Math.round(this.sbsl * 10000) / 10000;

                if (this.bhsj) {
                    this.bhse = Math.round(multiply(sl, bhsj) * 100) / 100;
                }
                if (this.hsj) {
                    this.hse = Math.round(multiply(sl, hsj) * 100) / 100;
                }
            })
            return data;
        },
        onSelect: function (rowIndex, rowData) {
            $(selected_xsht_kh).datagrid('appendRow', rowData);
        }
    });
}

//选中框的数据
var selected_xsht_kh = $('#xsht_kh_checked_grid').edatagrid({
            url: null,
            fitColumns: false,
            singleSelect: true,
            fit: true,
            checkbox: true,
            checkOnSelect: false,
            selectOnCheck: false,
            showFooter: false,
            rownumbers: true,
            frozenColumns: [
                [
                    {field: 'wzgg.id', title: '物资编码ID', hidden: true},
                    {field: 'kh.id', title: 'khID', hidden: true},
                    {field: 'wzgg.code', title: '物资编码', hidden: true},
                    {field: 'xszxh', title: '合同子项号', width: 85},
                    {field: 'wzgg.name', title: '品名', width: 100},
                    {field: 'wzgg.cz', title: '材质', width: 85},
                    {field: 'wzgg.ggxh', title: '规格', width: 85},
                    {field: 'carNo', title: '车皮号', width: 85},
                    {field: 'bindNo', title: '捆包号', width: 120}
                ]
            ],
            columns: [
                [
                    {field: 'kh.khbm', title: '卡号', width: 130},
                    {field: 'xscb', title: '库存单价',
                        formatter: function (value) {
                            var sl = formatJe(value, ",");
                            return sl;
                        }, width: 70},
                    {field: 'js', title: '件数',
                        formatter: function (value) {
                            var sl = formatSlForHtml(value, ",");
                            return sl;
                        }, width: 70},
                    {field: 'sbsl', title: '数量（吨）',
                        formatter: function (value) {
                            var sl = formatSlForHtml(value, ",");
                            return sl;
                        }, width: 100},
                    {field: 'hsj', title: '合同单价(含税)',
                        formatter: function (value) {
                            var sl = formatJe(value, ",");
                            return sl;
                        }, width: 100},
                    {field: 'bhsj', title: '合同单价(不含税)',
                        formatter: function (value) {
                            var sl = formatJe(value, ",");
                            return sl;
                        }, width: 100},
                    {field: 'hse', title: '含税额(元)',
                        formatter: function (value) {
                            var sl = formatJe2(value, ",");
                            return sl;
                        }, width: 100},
                    {field: 'bhse', title: '无税额(元)',
                        formatter: function (value) {
                            var sl = formatJe2(value, ",");
                            return sl;
                        }, width: 100}
                ]
            ],
            loadFilter: function (data) {
                $.each(data.rows, function () {
                    var bhsj = Math.round(this.bhsj * 10000) / 10000;
                    var hsj = Math.round(this.hsj * 10000) / 10000;
                    var sl = Math.round(this.sbsl * 10000) / 10000;

                    if (this.bhsj) {
                        this.bhse = Math.round(multiply(sl, bhsj) * 100) / 100;
                    }
                    if (this.hsj) {
                        this.hse = Math.round(multiply(sl, hsj) * 100) / 100;
                    }
                })
                return data;
            },
            onDblClickRow: function (rowIndex, rowData) {
                $("#xsht_kh_checked_grid").datagrid('deleteRow', rowIndex);
            }
        })
        ;
</script>
<div class="easyui-layout" data-options="fit:true">
    <input id="xshtId" hidden="true" value="${(xshtId)!}"/>

    <div data-options="region:'north',split:true" style="height:375px">
        <div id="toolbar_xshtkh_search" style="height:auto">
            <div class="textcon">
                <table class="tb" style="margin-left: 12px;">
                    <tr>
                        <th>合同子项号：</th>
                        <td><input name="xsxt_xsdh" type="text" class="input-text"/>
                        </td>
                        <th>车皮号：</th>
                        <td><input name="carNo" type="text" class="input-text">
                        </td>
                        <th>重量：</th>
                        <td><input name="weight" type="text" class="easyui-numberbox input-text"
                                   data-options="precision:4,min:0"/></td>
                        <th>捆绑号：</th>
                        <td><input name="bindNo" type="text" class="input-text"/></td>
                        <td>
                            <input id="btn_xshtkh_search_init" type="button" value=""
                                   class="submit"/></td>
                    </tr>
                </table>
            </div>
        </div>
        <table id="xsht_kh_grid"></table>
    </div>
    <div data-options="region:'center'">
        <table id="xsht_kh_checked_grid">
        </table>
    </div>
</div>